package com.wly.gpb {
	import com.netease.protobuf.*;
	use namespace com.netease.protobuf.used_by_generated_code;
	import com.netease.protobuf.fieldDescriptors.*;
	import flash.utils.Endian;
	import flash.utils.IDataInput;
	import flash.utils.IDataOutput;
	import flash.utils.IExternalizable;
	import flash.errors.IOError;
	import com.wly.gpb.Player;
	import com.wly.gpb.Fight.FightItem;
	// @@protoc_insertion_point(imports)

	// @@protoc_insertion_point(class_metadata)
	public dynamic final class Fight extends com.netease.protobuf.Message {
		/**
		 *  @private
		 */
		public static const TARGETID:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.wly.gpb.Fight.targetId", "targetId", (1 << 3) | com.netease.protobuf.WireType.VARINT);

		public var targetId:int;

		/**
		 *  @private
		 */
		public static const ENEMY:FieldDescriptor$TYPE_MESSAGE = new FieldDescriptor$TYPE_MESSAGE("com.wly.gpb.Fight.enemy", "enemy", (2 << 3) | com.netease.protobuf.WireType.LENGTH_DELIMITED, function():Class { return com.wly.gpb.Player; });

		private var enemy$field:com.wly.gpb.Player;

		public function clearEnemy():void {
			enemy$field = null;
		}

		public function get hasEnemy():Boolean {
			return enemy$field != null;
		}

		public function set enemy(value:com.wly.gpb.Player):void {
			enemy$field = value;
		}

		public function get enemy():com.wly.gpb.Player {
			return enemy$field;
		}

		/**
		 *  @private
		 */
		public static const FIGHTITEMS:RepeatedFieldDescriptor$TYPE_MESSAGE = new RepeatedFieldDescriptor$TYPE_MESSAGE("com.wly.gpb.Fight.fightItems", "fightItems", (3 << 3) | com.netease.protobuf.WireType.LENGTH_DELIMITED, function():Class { return com.wly.gpb.Fight.FightItem; });

		[ArrayElementType("com.wly.gpb.Fight.FightItem")]
		public var fightItems:Array = [];

		/**
		 *  @private
		 */
		public static const WINNER:FieldDescriptor$TYPE_INT32 = new FieldDescriptor$TYPE_INT32("com.wly.gpb.Fight.winner", "winner", (4 << 3) | com.netease.protobuf.WireType.VARINT);

		public var winner:int;

		/**
		 *  @private
		 */
		override com.netease.protobuf.used_by_generated_code final function writeToBuffer(output:com.netease.protobuf.WritingBuffer):void {
			com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 1);
			com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, this.targetId);
			if (hasEnemy) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.LENGTH_DELIMITED, 2);
				com.netease.protobuf.WriteUtils.write$TYPE_MESSAGE(output, enemy$field);
			}
			for (var fightItems$index:uint = 0; fightItems$index < this.fightItems.length; ++fightItems$index) {
				com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.LENGTH_DELIMITED, 3);
				com.netease.protobuf.WriteUtils.write$TYPE_MESSAGE(output, this.fightItems[fightItems$index]);
			}
			com.netease.protobuf.WriteUtils.writeTag(output, com.netease.protobuf.WireType.VARINT, 4);
			com.netease.protobuf.WriteUtils.write$TYPE_INT32(output, this.winner);
			for (var fieldKey:* in this) {
				super.writeUnknown(output, fieldKey);
			}
		}

		/**
		 *  @private
		 */
		override com.netease.protobuf.used_by_generated_code final function readFromSlice(input:flash.utils.IDataInput, bytesAfterSlice:uint):void {
			var targetId$count:uint = 0;
			var enemy$count:uint = 0;
			var winner$count:uint = 0;
			while (input.bytesAvailable > bytesAfterSlice) {
				var tag:uint = com.netease.protobuf.ReadUtils.read$TYPE_UINT32(input);
				switch (tag >> 3) {
				case 1:
					if (targetId$count != 0) {
						throw new flash.errors.IOError('Bad data format: Fight.targetId cannot be set twice.');
					}
					++targetId$count;
					this.targetId = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				case 2:
					if (enemy$count != 0) {
						throw new flash.errors.IOError('Bad data format: Fight.enemy cannot be set twice.');
					}
					++enemy$count;
					this.enemy = new com.wly.gpb.Player();
					com.netease.protobuf.ReadUtils.read$TYPE_MESSAGE(input, this.enemy);
					break;
				case 3:
					this.fightItems.push(com.netease.protobuf.ReadUtils.read$TYPE_MESSAGE(input, new com.wly.gpb.Fight.FightItem()));
					break;
				case 4:
					if (winner$count != 0) {
						throw new flash.errors.IOError('Bad data format: Fight.winner cannot be set twice.');
					}
					++winner$count;
					this.winner = com.netease.protobuf.ReadUtils.read$TYPE_INT32(input);
					break;
				default:
					super.readUnknown(input, tag);
					break;
				}
			}
		}

	}
}
